#include "Scene/IRenderQueueGroup.h"

#include "Framework/StableHeaders.h"

#include "Scene/IRenderPriorityGroup.h"

namespace tyro
{
	namespace Scene
	{


		void IRenderQueueGroup::AddRenderable( Graphics::IRenderable* rend, Graphics::Technique* tech, UINT_16 priority )
		{
			// Find the priority map
			PriorityGroupMap::iterator i = priorityGroupMap.find(priority);
			IRenderPriorityGroup* priorityGroup;

			
			if (i == priorityGroupMap.end())
			{
				// Create map if needed
				priorityGroup = new IRenderPriorityGroup();
				priorityGroupMap.insert(PriorityGroupMap::value_type(priority, priorityGroup));
			}
			else
			{
				priorityGroup = i->second;
			}

			// Add the renderable to prioritised group
			priorityGroup->AddRenderable(rend, tech);

		}

		IRenderQueueGroup::IRenderQueueGroup()
		{

		}

		const IRenderQueueGroup::PriorityGroupMap& IRenderQueueGroup::GetPriorityMap( void ) const
		{
			return priorityGroupMap;
		}

	}
}